$(document).ready(function(){
	$("#myCont01 > div:not(:first)").hide();
	var myLi = $("#myTop01 > ul > li");
	var myDiv =$("#myCont01 > div.w_box_bg");
	myLi.each(function(i){
		$(this).click(function(){
			myLi.removeClass("hover");
			$(this).addClass("hover");
			myDiv.hide();
			myDiv.eq(i).show();
		})
	})

})


$(document).ready(function(){
	var myLi = $("#xiangzhenTop > ul > li");
	var myDiv =$("#xiangzhenCont > div");
	myLi.each(function(i){
	   $(this).click(function(){
		 myLi.removeClass("hover");
		  $(this).addClass("hover");
		   myDiv.hide();
		   myDiv.eq(i).show();
	   })
	})
})

function initSelectYear()
{
	var defaultyear = defaultmon.substr(0, 4);
	var options = '';

	$(years).each(function(i, year){
		options += '<option value="' + year + '"';
		if (year == defaultyear) {
			options += ' selected="selected"';
		}
		options += '>' + year + '��</option>';
	})

	$("#selectyear").html(options);
}

function initSelectMonth(year, selmon)
{
	var options = '<option value="">ѡ����</option>';

	$(months[year]).each(function(i, month){
		options += '<option value="' + month + '"';
		if (selmon == year+month) {
			options += ' selected="selected"';
		}
		options += '>' + month + '��</option>';
	})

	$("#selectmonth").html(options);
}

function loadweapic(month)
{
	$("#weapic").hide();
	if (weapics[month] && weapics[month] != undefined) {
		$("#weapic > img").attr('src', weapics[month]);
		$("#weapic").show();
		return false;
	}

	var url = 'http://www.tianqi.com/index.php?c=historywea&a=getweapic&' + $("#historywea").attr('cityinfo') + '&month=' + month + '&jsoncallback=?';
	$.getJSON(url,
	function(data){
		var weapic = data.src;
	 	if (weapic) {
	  		weapics[month] = weapic;
	  		$("#weapic > img").attr('src', weapics[month]);
	  	} else {
			$("#weapic > img").attr("alt", '����ͼƬʧ��');
	  	}
	  	$("#weapic").show();
	});
	return false;
}

function ietester() {
var undef,
	ie,
	v = 3,
	div = document.createElement('div'),
	all = div.getElementsByTagName('i');
while (
		div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
		all[0]
	);
v > 4 ? ie = v : ie = undef;
return ie;
}

$(function () {
if ($(".fix_div").length > 0) {
	var top = $(".fix_parent").offset().top;
	var left = $(".fix_parent").offset().right;

	var ie = ietester();

	$(window).scroll(function () {
		var limit = $(".mian").offset().top + $(".mian").height() - $(".fix_div").height();
		if ($(window).scrollTop() >= limit) {
			$(".fix_div").css({ position: "absolute", top: limit, right:"50%", marginRight: "-479px"  });

		} else {
			if (top <= $(window).scrollTop()) {
				if (ie <= 6) {
					$(".fix_div").css({ position: "absolute", top: ($(window).scrollTop()), right: "50%", marginRight:"-479px" });
				} else {
					$(".fix_div").css({ position: "fixed", top: 0, right:"50%", marginRight: "-479px" });
				}
			} else {
				$(".fix_div").css({ position: "static", top: 0, marginRight: "0px" });
			}
		}
	});
}
});